<!DOCTYPE html>
<html lang="en" debug="true">
<head>
    <meta charset="UTF-8">
    <title>PalmPlatform DevTool</title>
  <link rel="stylesheet" href="css/app.css"/>
  <link rel="stylesheet" href="css/framework.css"/>
  <style>
    html,body,#app{
      height: 100%;
      width: 100%;
      overflow: hidden;
      user-select: none;
    }
  </style>
</head>
<body>

<div id="app" >

</div>
<div id="per-loader" class="loader">
  <div class="loader-inner"></div>
</div>
<script src="js/loader.min.js"></script>
<!--<script src="js/framework.js"></script>-->
<script>
    require.config({
        baseUrl: "./",
        paths: {
            //vue: location.search == '?debug' ? "js/lib/vue.2.6.12" : 'js/lib/vue.2.6.12.min',
            Vuex: 'js/lib/vuex.3.5.1.min',
            HeyUI: 'js/lib/heyui',
            vueRouter: 'js/lib/vue-router.3.5.1.min',
            G: 'js/lib/hey-global',
            axios: 'js/lib/axios',
            sortablejs: 'js/lib/sortable.min',//CDN 'http://www.itxst.com/package/sortable/Sortable.min',
            vuedraggable: 'js/lib/vuedraggable.umd.min',//CDN 'http://www.itxst.com/package/vuedraggable/vuedraggable.umd.min',
            plupload: 'js/lib/plupload.min',
            moxie: 'js/lib/moxie.min',
            vs: 'js/vs',
            echarts: 'js/lib/echarts.min',//'https://cdn.bootcdn.net/ajax/libs/echarts/5.1.2/echarts.min',
            lodash_debounce: 'https://cdn.jsdelivr.net/npm/lodash.debounce@4.0.8/index.min',
            XLSX: 'js/lib/xlsx.full.min',
            wangEditor:'js/lib/wangEditor.min',
            framework:'js/framework'
        }
    })
    require(['dev','framework','vue','vueRouter'],function(index,framework,Vue,VueRouter){
        Vue.use(VueRouter)
        let axios=framework.axios;
        let HeyUI=framework.HeyUI
        HeyUI.addDict("verify",{
            IDCardNo:'身份证',
            CnMobile:'手机号',
            Email:'邮箱',
            tel:'电话号码',
            url:'网址'
        })

        axios.interceptors.response.use(function (res) {
            if (res && res.data && res.data.code != 200) {
                if (res.data.code == 401 || res.data.code == 403) {
                    location.hash = "/login"
                    return Promise.reject(res.data);
                }
                HeyUI.$Message({type: 'error', text: res.data.message})
                return Promise.reject(res.data)
            } else {
                return res.data;
            }
        }, function (error) {
            // 对响应错误做点什么;没有权限401，去登录界面
            if (error.response.status === 401) {
                // window.$toast('登录超时')
                location.hash = "/login"
            } else if (error.response.status === 403) {
                // window.$toast('暂无权限')
                location.hash = "/login"
            } else if (error.response.status === 500) {
                // window.$toast('网络错误')
                HeyUI.$Message({type: 'error', text: "服务器错误！"})
            } else if (error.response.status === 404) {
                // window.$toast('网络错误')
                HeyUI.$Message({type: 'error', text: "404 NOT FOUND！"})
            }
            return Promise.reject(error);
        });

        axios.get('dev/dicts').then(res=>{
            HeyUI.addDict("dicts",res.data)
        })
        axios.get('dev/translates').then(res=>{
            HeyUI.addDict("translates",res.data)
        })
        let routes= [{
            name:'index',
            path: '/', component:index,
            children:[
                {
                    name:'models',
                    path:'/models',
                    component:(r)=>require(['models'],r)
                },
                {
                    name:'genTool',
                    path:'/genTool',
                    component:(r)=>require(['genTools'],r)
                },
                {
                    name:'menu',
                    path:'/menu',
                    component:(r)=>require(['menus'],r)
                },
                {
                    name:'report',
                    path:'/report',
                    component:(r)=>require(['report'],r)
                }
            ]
        }]
        let router=new VueRouter({routes:routes});
        framework.init("#app",{
            template:'<div id="app"><router-view/></div>', router:router,
        })
    })
</script>
</body>
</html>
